<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Adds a server alias to the HTTP server object</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="eventhttp.accept.html">EventHttp::accept</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="eventhttp.bind.html">EventHttp::bind</a></div>
 <div class="up"><a href="class.eventhttp.html">EventHttp</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="eventhttp.addserveralias" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">EventHttp::addServerAlias</h1>
  <p class="verinfo">(PECL event &gt;= 1.4.0-beta)</p><p class="refpurpose"><span class="refname">EventHttp::addServerAlias</span> &mdash; <span class="dc-title">Adds a server alias to the HTTP server object</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-eventhttp.addserveralias-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span> 
   <span class="methodname"><strong>EventHttp::addServerAlias</strong></span>
    ( <span class="methodparam">
    <span class="type">string</span>
     <code class="parameter">$alias</code>
   </span>
   )</div>

  <p class="para rdfs-comment">
   Adds a server alias to the HTTP server object.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-eventhttp.addserveralias-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>

     <em><code class="parameter">alias</code></em>
    </dt>

    <dd>

     <p class="para">
      The alias to add.
     </p>
    </dd>

   
  </dl>

 </div>

 <div class="refsect1 returnvalues" id="refsect1-eventhttp.addserveralias-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns <strong><code>TRUE</code></strong> on success. Otherwise <strong><code>FALSE</code></strong>.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-eventhttp.addserveralias-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-4171">
   <p><strong>Example #1 
    <span class="function"><strong>EventHttp::addServerAlias()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$base&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">EventBase</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$http&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">EventHttp</span><span style="color: #007700">(</span><span style="color: #0000BB">$base</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$socket&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">socket_create</span><span style="color: #007700">(</span><span style="color: #0000BB">AF_INET</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SOCK_STREAM</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SOL_TCP</span><span style="color: #007700">);<br /><br />if&nbsp;(!</span><span style="color: #0000BB">$http</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">bind</span><span style="color: #007700">(</span><span style="color: #DD0000">"127.0.0.1"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">8088</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;exit(</span><span style="color: #DD0000">"bind(1)&nbsp;failed\n"</span><span style="color: #007700">);<br />};<br /><br />if&nbsp;(!</span><span style="color: #0000BB">$http</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addServerAlias</span><span style="color: #007700">(</span><span style="color: #DD0000">"local.net"</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;exit(</span><span style="color: #DD0000">"Failed&nbsp;to&nbsp;add&nbsp;server&nbsp;alias\n"</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$http</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setCallback</span><span style="color: #007700">(</span><span style="color: #DD0000">"/about"</span><span style="color: #007700">,&nbsp;function(</span><span style="color: #0000BB">$req</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"URI:&nbsp;"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$req</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getUri</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$req</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">sendReply</span><span style="color: #007700">(</span><span style="color: #0000BB">200</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"OK"</span><span style="color: #007700">);<br />});<br /></span><span style="color: #0000BB">$base</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">dispatch</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>

 <div class="refsect1 seealso" id="refsect1-eventhttp.addserveralias-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member">
    <span class="methodname"><a href="eventhttp.removeserveralias.html" class="methodname" rel="rdfs-seeAlso">EventHttp::removeServerAlias()</a> - Removes server alias</span>
   </li>
  </ul>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="eventhttp.accept.html">EventHttp::accept</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="eventhttp.bind.html">EventHttp::bind</a></div>
 <div class="up"><a href="class.eventhttp.html">EventHttp</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
